package common

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type RespResult struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func OK(c *gin.Context) {
	var res RespResult
	res.Code = 200
	res.Msg = "ok"
	c.JSON(http.StatusOK, res)
}

func OkMsg(c *gin.Context, msg string) {
	var res RespResult
	res.Code = 200
	res.Msg = msg
	c.JSON(http.StatusOK, res)
}

func OkData(c *gin.Context, data interface{}) {
	var res RespResult
	res.Code = 200
	res.Msg = "ok"
	res.Data = data
	c.JSON(http.StatusOK, res)
}

func Error(c *gin.Context, code int, msg string) {
	var res RespResult
	res.Code = code
	res.Msg = msg
	c.JSON(http.StatusOK, res)
}
